<template>
  <div class="wh-quality" :class="{ active: isStart, out: !isStart }">
    <div class="inner" ref="triggerDom">
      <div class="wh-quality-left">
        <h3 class="fs48">高质量数据处理与训练</h3>
        <p class="fs48">语言资产有效沉淀，提高利用率</p>
        <ul>
          <li>
            <img src="../../assets/images/home/all-right.png" alt="right" />
            <p>
              建立从语料在线对齐、语料检索、语料匹配 <br />
              再到语料训练的完整生态链
            </p>
          </li>
          <li>
            <img src="../../assets/images/home/all-right.png" alt="right" />
            <p>
              高质量的语言资产可让翻译结果的准确度显著提升， <br />
              以创造更好的用户体验。
            </p>
          </li>
        </ul>
      </div>
      <div class="wh-quality-right">
        <div class="round"></div>
        <div class="round-inner"></div>
        <div class="dot"></div>
        <dl>
          <dt></dt>
          <dt></dt>
          <dd>
            <span></span>
            <span></span>
          </dd>
        </dl>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useScroll } from '@/hooks'

const { triggerDom, isStart } = useScroll()
</script>

<style scoped lang="scss">
@import '@/assets/scss/base.scss';

@keyframes round-inner {
  to {
    transform: rotate(1turn);
  }
}

@keyframes round {
  to {
    transform: rotate(-1turn);
  }
}

@keyframes dot-play {
  to {
    width: 60px;
    height: 60px;
    opacity: 0;
  }
}

@keyframes dot-border {
  to {
    width: 80px;
    height: 80px;
  }
}

.wh-quality {
  margin: 0 auto;
  padding: 230px 0;

  .inner {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  &.active {
    .wh-quality-left {
      > h3,
      > p,
      > ul {
        opacity: 1;
        transform: translateY(0);
      }

      > h3 {
        transition: all 1s $cubic;
      }

      > p {
        transition: all 1s 0.3s $cubic;
      }

      > ul {
        transition: all 1s 0.6s $cubic;
      }
    }

    .wh-quality-right {
      > dl > dt {
        transform: scaleX(1);
        @for $i from 1 through 2 {
          &:nth-of-type(#{$i}) {
            transition: all 1s 0.3s * ($i - 1);
          }
        }
      }

      > dl > dd {
        > span {
          @for $i from 1 through 2 {
            &:nth-of-type(#{$i}) {
              transition: all 1s 0.3s * ($i + 1) $cubic;
              transform: scale(1);
              opacity: 1;
            }
          }
        }
      }
    }
  }

  &.out {
    .wh-quality-left {
      > h3,
      > p,
      > ul {
        opacity: 0;
        transform: translateY(40px);
      }

      > h3 {
        transition: all 1s 0.6s $cubic;
      }

      > p {
        transition: all 1s 0.3s $cubic;
      }

      > ul {
        transition: all 1s $cubic;
      }
    }

    .wh-quality-right {
      dl dt {
        transform: scaleX(0);
        @for $i from 1 through 2 {
          &:nth-of-type(#{$i}) {
            transition: all 1s 0.3s * (3 - $i);
          }
        }
      }

      dl dd {
        > span {
          transform: scale(0);
          opacity: 0;
          @for $i from 1 through 2 {
            &:nth-of-type(#{$i}) {
              transition: all 1s 0.3s * (2 - $i) $cubic;
            }
          }
        }
      }
    }
  }

  .wh-quality-left {
    padding-left: 170px;

    > h3,
    > p {
      opacity: 0;
      transform: translateY(40px);
    }

    ul {
      margin-left: -110px;
      padding-top: 67px;
      transform: translateY(40px);
      opacity: 0;

      li {
        box-sizing: border-box;
        padding: 47px 0 39px 26px;
        width: 760px;
        height: 154px;
        font-size: 24px;
        font-weight: 300;
        color: #6c7e94;
        display: flex;

        > img {
          visibility: hidden;
          width: 57px;
          min-width: 57px;
          object-fit: contain;
          margin-right: 27px;
        }

        &:hover,
        &.active {
          border-radius: 26px;
          background: #ffffff;
          box-shadow: 54px 36px 68px 0 rgba(140, 180, 238, 0.15);

          > img {
            visibility: visible;
          }
        }
      }
    }
  }

  .wh-quality-right {
    position: relative;
    display: flex;
    width: 880px;
    height: 595px;
    background: url('@/assets/images/home/quality.png') no-repeat 0 0;

    > .dot {
      width: 18px;
      height: 18px;
      background-color: #377dea;
      border-radius: 50%;
      position: absolute;
      z-index: 10;
      left: 60px;
      top: 320px;

      &::before,
      &::after {
        content: '';
        position: absolute;
        z-index: 5;
        left: 50%;
        top: 50%;
        transform: translateX(-50%) translateY(-50%);
        width: 0;
        height: 0;
        border-radius: 50%;
      }

      &::before {
        border: 1px solid rgba(78, 156, 252, 0.12);
        animation: dot-border 1s infinite;
      }

      &::after {
        background-color: rgba(78, 156, 252, 1);
        animation: dot-play 1s infinite;
      }
    }

    > .round {
      position: absolute;
      left: 324px;
      top: 160px;
      width: 180px;
      height: 180px;
      border-radius: 50%;
      background: url('@/assets/images/home/quality-bg.png') no-repeat 0 0;
      animation: round 1s linear infinite;
    }

    > .round-inner {
      position: absolute;
      left: 287px;
      top: 123px;
      width: 255px;
      height: 255px;
      border-radius: 50%;
      background: url('@/assets/images/home/round.png') no-repeat 0 0;
      animation: round-inner 2s linear infinite;
    }

    > dl {
      position: absolute;
      left: 560px;
      top: 200px;

      > dt {
        width: 160px;
        transform-origin: left center;
        transform: scaleX(0);
        height: 8px;
        background-color: #42b2f3;
        border-radius: 34px;
        margin-bottom: 35px;

        &:nth-of-type(2) {
          max-width: 132px;
          background-color: #40cca7;
        }
      }

      > dd {
        > span {
          display: inline-block;
          width: 17px;
          height: 17px;
          border-radius: 50%;
          background-color: #40cca7;
          opacity: 0;
          transform: scale(0);

          &:nth-of-type(2) {
            margin-left: 10px;
            background-color: #3b7de5;
          }
        }
      }
    }
  }
}
</style>
